package io.github.jsp.dao;


import java.util.List;

import io.github.jsp.model.Task;
import io.github.jsp.model.TaskExecution;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface TaskMapper {
    List<Task> findAllEnabledTasks();
    Task findTaskById(int id);
    int insertTask(Task task);
    int updateTask(Task task);
    int deleteTask(int id);
    
    int acquireTaskLock(@Param("taskId") int taskId, @Param("serverId") String serverId);
    int updateHeartbeat(@Param("taskId") int taskId, @Param("serverId") String serverId);
    int releaseTaskLock(@Param("taskId") int taskId, @Param("serverId") String serverId);
    int cleanExpiredLocks();
    
    int recordTaskExecutionStart(TaskExecution execution);
    int updateTaskExecutionResult(TaskExecution execution);
    List<TaskExecution> findTaskExecutionHistory(int taskId);
}